/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bitcore.servicios;

import bitcore.mappings.TaxiController;
import bitcore.mappings.Taxista;
import java.util.List;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
 *
 * @author julio jw0rmc
 */
@WebService(serviceName = "ServicioTaxero")
public class ServicioTaxero {
    private TaxiController tc=new TaxiController();
    private List<Taxista> lt;

    /**
     * This is a sample web service operation
     */
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        return "Hello " + txt + " !";
    }

    /**
     * Web service operation
     */
    @WebMethod(operationName = "TaxByExt")
    public String TaxByExt(@WebParam(name = "miny") String miny, @WebParam(name = "maxy") String maxy, @WebParam(name = "minx") String minx, @WebParam(name = "maxx") String maxx) {
        //TODO write your implementation code here:
        String cadenon="";
        lt=tc.getTaxiss(Double.parseDouble(miny), Double.parseDouble(maxy), Double.parseDouble(minx), Double.parseDouble(maxx));
        
        for(Taxista taxista: lt){  
     cadenon+=taxista.getId() +  ":"+ taxista.getNombre()+":"+taxista.getLatActual()+":"+taxista.getLonActual()+",";
     System.out.println(cadenon);
        }
        
        return cadenon;
    }
    
    
     /**
     * Web service operation
     */
    @WebMethod(operationName = "UpdateTaxyByID")
    public void UpdateTaxyByID(@WebParam(name = "id") String id, @WebParam(name = "lat") String lat, @WebParam(name = "lon") String lon) {
        //TODO write your implementation code here:
    tc.updateTaxiPosicionById(id, lat, lon);
    }
    
    
    @WebMethod(operationName = "PosicionAcualByID")
    public String PosicionByID(@WebParam(name = "id") String id) {
        
        Taxista t=tc.testTaxi(id);
        
        return ""+t.getLatActual()+","+t.getLonActual();
    }
    
}
